<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport"
			content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<link rel="stylesheet" href="../../../../layuiadmin/layui/css/layui.css" media="all">
		<link rel="stylesheet" href="../../../../layuiadmin/style/admin.css" media="all">
		<link rel="stylesheet" href="../../../../css/common.css" media="all">

	</head>

	<body>

		<div class="layui-fluid">
			<div class="layui-row" id="view">
				<form class="layui-form test_edit" lay-filter="test_detail">
					<div class="layui-card">
						<div class="layui-card-body">

							<div class="layui-card">
								<div class="layui-card-body">
									<div class="layui-form-item">
										<label class="layui-form-label">操作类型：</label>
										<div class="layui-input-block">
											<input type="radio" name="opreation" value="1" title="按分组" lay-filter="demo-radio-filter">
											<!-- <input type="radio" name="status" value="0" title="待审核"> -->
											<input type="radio"  name="opreation" value="2" title="按选择" lay-filter="demo-radio-filter">
										</div>
									</div>
									<div class="layui-form-item" id="chooseGroup" style="display: none;">
										<label class="layui-form-label">请选择：</label>
										<div class="layui-input-block">
											<select id="mySelect">
												<option value="">请选择</option>
												<!-- <option value="AAA">选项 A</option>
												<option value="BBB">选项 B</option>
												<option value="CCC">选项 C</option> -->
											</select>
										</div>
									</div>
									<!-- <div class="layui-col-md6">
									   
									  </div> -->
									<div class="layui-form-item">
										<label class="layui-form-label">审核状态：</label>
										<div class="layui-input-block">
											<input type="radio" name="audit_status" value="1" title="不通过">
											<!-- <input type="radio" name="status" value="0" title="待审核"> -->
											<input type="radio" name="audit_status" value="2" title="通过" checked="">
										</div>
									</div>
									<div class="layui-form-item">
										<label class="layui-form-label">审核意见：</label>
										<div class="layui-input-block">
											<textarea name="audit_desc" placeholder="请输入审核意见" class="layui-textarea"></textarea>
											<!-- <input type="text" name="audit_desc" placeholder="请输入审核意见" autocomplete="off"
												class="layui-input"> -->
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
					<div class="layui-form-item layui-layout-admin">
						<div class="layui-input-block">
							<div class="layui-footer" style="left: 0;">
								<button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
							</div>
						</div>
					</div>
				</form>
			</div>
		</div>
		<script src="../../../../layuiadmin/layui/layui.js"></script>
		<script src="../../../../js/jquery.min.js"></script>
		<script src="../../../../js/jquery.jqprint-0.3.js"></script>
		<script src="../../../../js/common.js"></script>
		<!-- <script src="https://webapi.amap.com/maps?v=1.4.15&key=2d30eff9da600d78fba843b033c4eecd"></script> -->
		<script>
			// var groupList=localStorage.getItem('groupList')
			// groupList=JSON.parse(groupList) 
			var _data = {}
			var ids=[]
			var checkStatus = parent.layui.table.checkStatus('test-table-operate');
			for(var i=0;i<checkStatus.data.length;i++){
				ids.push(checkStatus.data[i].id)
			}
			function child(dataFromFather) {
				groupList=dataFromFather
				for(var i=0;i<groupList.length;i++){
					var option = $("<option>").text(groupList[i].groupname); // 创建一个新的 option 元素
					$('#mySelect').append(option)
				}
			}
			layui.config({
				base: '../../../../layuiadmin/' //静态资源所在路径
			}).extend({
				index: 'lib/index' //主入口模块
			}).use(['index', 'form', 'laytpl', 'laydate', 'layedit', 'rate', 'upload'], function() {
				var $ = layui.$,
					admin = layui.admin,
					laytpl = layui.laytpl,
					laydate = layui.laydate,
					upload = layui.upload,
					form = layui.form;
				var rate = layui.rate;
				var img_arr3 = [],
					img_arr1 = [],
					img_arr10 = [],
					img_arr2 = []
				img_arr4 = []
				//渲染
				var ins1 = rate.render({
					elem: '#score', //绑定元素
					half: true,
					value: _data.score,
					choose: function(value) {
						_data.score = value;
					}
				});

				sex_show('radio');

				service_type_show('checkbox');


                // radio 事件
                form.on('radio(demo-radio-filter)', function(data){
                    var elem = data.elem; // 获得 radio 原始 DOM 对象
                    var checked = elem.checked; // 获得 radio 选中状态
                    var value = elem.value; // 获得 radio 值
                    var othis = data.othis; // 获得 radio 元素被替换后的 jQuery 对象
					if(value==1&&checked){
						$('#chooseGroup').css('display','block')
					}else if(value==2&&checked){
						if(ids.length>0){
							ids=ids.join(',')
						}else{
							$('#choose').attr('checked',false)
							layer.msg('请选择');
						}
						$('#chooseGroup').css('display','none')
					}
                    // layer.msg(['value: '+ value, 'checked: '+ checked].join('<br>'));
                });


				//监听提交
				form.on('submit(demo1)', function(data) {
					 // 阻止表单的默认提交行为
					event.preventDefault();
					var data = data.field;
					_data = Object.assign(_data, data);
					var lock = false;
					if(_data.opreation==1){
						_data.gname=$('#mySelect').val()
						// _data.gname='636'
						if(_data.gname==''){
							layer.msg('分组名称不能为空');
							return;
						}
					}else{
						if(ids.length>0){
							// _data.id=ids.join(',')
							_data.id=ids
						}else{
							layer.msg('请选择要审核的数据');
							return;
						}
					}
					var lock = false
					layer.confirm('确定要提交数据？', function() {
						if (!lock) {
							lock = true
							loading();
							submitdata(server.sys_shop_cash_out_check);
						}
					}, function() {
						layer.msg('取消操作');
					});
					return false;
				});
                // 设置某行选中
              
				function submitdata(_url) {
					
					$.post(_url, _data, function(res, status) {
						if(status == 'success') {
							if(res.code == 0) {
								layer.alert('操作成功', function() {
									parent.layer.closeAll();
									ids=[]
									parent.layui.table.reload('test-table-operate');
								});
							} else {
								layer.msg(res.msg);
							}
							closeloading();
						} else {
							closeloading();
							layer.msg('服务器连接错误');
						}
					});

					// $.get(_url, _data, function(res, status) {
					// 	console.log("看看提交的数据", _url, _data);
					// 	if (status == 'success') {
					// 		if (res.code == 0) {
					// 			console.log("修改成功后的", res);
					// 			layer.alert('操作成功', function() {
					// 				parent.layer.closeAll();
					// 				parent.layui.table.reload('test-table-operate');
					// 			});
					// 		} else {
					// 			layer.msg(res.msg);
					// 		}
					// 		closeloading();
					// 	} else {
					// 		closeloading();
					// 		layer.msg('服务器连接错误');
					// 	}
					// });
				};
			});
		</script>
	</body>

</html>